<template>
  <div class="pbody">
    <div class="" v-if="active == 1 || active == 2">
      <el-form :inline="true" :model="queryParams" class="demo-form-inline">
        <el-form-item>
          <el-input
            v-model="queryParams.code"
            placeholder="请输入需要核销的券码"
            style="width: 520px"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="onSearch"
          ></el-button>
        </el-form-item>
      </el-form>
      <img
        v-if="active == 1"
        src="@/assets/images/u12365.png"
        class="oneimg mb_30"
        alt=""
      />
      <el-table
        v-if="active == 2"
        v-loading="loading"
        :data="list"
        border
        ref="tablelayout"
        class="commtable"
      >
        <el-table-column label="卷码" prop="time" align="center" />
        <el-table-column label="活动编号" prop="id" align="center" />
        <el-table-column label="奖项等级" prop="time" align="center" />
        <el-table-column label="奖品名称" prop="time" align="center" />
        <el-table-column label="中奖者" prop="time" align="center" />
        <el-table-column label="中奖时间" prop="time" align="center" />
        <el-table-column label="券码状态" prop="time" align="center" />
        <el-table-column label="操作" width="80" align="center" fixed="right">
          <template slot-scope="scope">
            <div class="flex">
              <div
                class="commhover btn_green c_fff"
                @click="handleHx(scope.row)"
              >
                <svg-icon icon-class="fabu" class-name="f-14" /> 核销
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.page"
        :limit.sync="queryParams.num"
        @pagination="getList"
      />
    </div>
    <div v-if="active == 3">
      <div class="cardbox">
        <div class="flexrowbetween bor_b">
          <div class="c_000">一等奖：吹风机</div>
          <el-tag type="danger">未核销</el-tag>
        </div>
        <div class="flex mb_15 mt_15">
          <div class="title flex aligncenter c_000 f-13">获奖人</div>
          <div class="content flex aligncenter f-13 c_000">
            <img src="" alt="" class="avatar mr_15" />
            用户1
          </div>
        </div>
        <div class="flex mb_15">
          <div class="title c_000 f-13">活动</div>
          <div class="content c_000 f-13">活动3 参与活动赢大奖</div>
        </div>
        <div class="flex mb_15">
          <div class="title c_000 f-13">券号</div>
          <div class="content c_000 f-13">123456789</div>
        </div>
        <div class="flex mb_15 bor_b">
          <div class="title c_000 f-13">兑奖期限</div>
          <div class="content c_000 f-13">
            2023-06-15 00:00-2023-09-12 23:59
          </div>
        </div>
        <div class="title c_000 f-13 mb_15">核销备注</div>
        <el-input
          v-model="remark"
          size="mini"
          placeholder="最多输入40个汉字或40个英文字母"
        ></el-input>
        <div class="bor_b"></div>
        <el-form 
          :model="form"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="mt_15 labelsty"
        >
          <el-form-item label="地址信息：" prop="address">
            <el-cascader v-if="!status"
              v-model="form.address"
              :options="options"
              :props="{ expandTrigger: 'hover' }"
              @change="handleChange"
            ></el-cascader>
            <span v-if="status">湖南省长沙市</span>
          </el-form-item>
          <el-form-item label="详细地址：" prop="detail">
            <el-input v-if="!status"
              v-model="form.detail"
              type="textarea"
              rows="3"
              placeholder="请输入相似地址信息，如道路、门牌号、小区、楼栋号、单元等信息"
            ></el-input>
            <span v-if="status">湖南省长沙市</span>
          </el-form-item>
          <el-form-item label="邮政编码：" prop="emailcode">
            <el-input v-if="!status"
              v-model="form.emailcode"
              placeholder="请填写邮编"
            ></el-input>
            <span v-if="status">422000</span>
          </el-form-item>
          <el-form-item label="收货人姓名：" prop="username">
            <el-input v-if="!status"
              v-model="form.username"
              placeholder="长度不超过25字符"
              maxlength="25"
            ></el-input>
            <span v-if="status">张三</span>
          </el-form-item>
          <el-form-item label="手机号码：" prop="phone">
            <el-input v-if="!status"
              v-model="form.phone"
              placeholder="电话号码、手机号码必须填一项"
            ></el-input>
            <span v-if="status">13300000000</span>
          </el-form-item>
        </el-form>

      </div>
      <div class="flexcenter mt_20">
        <el-button type="danger" v-if="status==0" class="mlr_40" @click="submitHx">立即核销</el-button>
        <el-button type="" v-if="status==0" class="mlr_40" @click="onSearch">返回上级</el-button>
        <el-button type="danger" v-if="status==1" class="mlr_40" @click="revocation">撤回核销</el-button>
        <el-button type="" v-if="status==1" class="mlr_40" @click="onClose">返回核销管理</el-button>
      </div>
    </div>
    <el-steps v-if="active == 1" :active="active" finish-status="success">
      <el-step title="搜索卡券"></el-step>
      <el-step title="校验"></el-step>
      <el-step title="完成使用"></el-step>
    </el-steps>
  </div>
</template>
<script>
import { mapState } from "vuex";
import { validPhone } from "@/utils/validate";
export default {
  data() {
    return {
      active: 1,
      queryParams: {
        page: 1,
        num: 10,
        code: "",
      },
      loading: false,
      list: [{ id: 1 }],
      total: 0,
      rowinfo: null,
      remark:'',//备注
      status:0,//状态 
      form: {},
      rules: {
        address:[
          { required: true, message: "地址信息不能为空", trigger: "blur" },
        ],
        detail: [
          { required: true, message: "请输入详细地址", trigger: "blur" },
          { min: 5, max: 120, message: "长度在 5 到 120 个字符", trigger: "blur"},
        ],
        // emailcode: [
        //   { type: "email", message: "请输入正确的邮箱地址",trigger: ["blur", "change"] }
        // ],
        username: [
          { required: true, message: "收货人姓名不能为空", trigger: "blur" },
        ],
        phone: [{ required: true, validator: validPhone, trigger: "blur" }],
      },
      options: [
        {
          value: "zhinan",
          label: "指南",
          children: [
            {
              value: "shejiyuanze",
              label: "设计原则",
              children: [
                {
                  value: "yizhi",
                  label: "一致",
                },
                {
                  value: "fankui",
                  label: "反馈",
                },
                {
                  value: "xiaolv",
                  label: "效率",
                },
                {
                  value: "kekong",
                  label: "可控",
                },
              ],
            },
          ],
        },
      ],
    };
  },

  computed: {},

  created() {},

  methods: {
    getList() {},

    handleHx(row) {
      this.rowinfo = row;
      this.active = 3;
    },
    onSearch() {
      this.active = 2;
    },
    handleChange(){

    },

    submitHx(){
      // this.$refs.form.validate(valid=>{
      //   if(!valid)return
        
      // })
      this.status = 1
    },

    revocation(){
      this.status = 0
    },

    onClose(){
      this.$emit('close')
    }
  },
};
</script>

<style lang="scss" scoped>
.pbody {
  padding: 0 20px;
}
.oneimg {
  width: 320px;
}
.cardbox {
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 15px;
}
.bor_b {
  padding-bottom: 10px;
  border-bottom: 1px dotted #eee;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.title {
  width: 120px;
}
.content {
  width: calc(100% - 120px);
}
.labelsty {
  ::v-deep .el-form-item__label {
    font-size: 13px;
    font-weight: normal;
    color: #000;
  }
}
</style>